package com.renchi.menu.Collection.controller;

import com.renchi.menu.Collection.entity.CollectionDbEntity;
import com.renchi.menu.Collection.service.CollectionDbService;
import com.renchi.menu.Collection.vo.CollectionDbVo;
import com.renchi.menu.common.page.PageInfo;
import com.renchi.menu.common.result.Result;
import com.renchi.menu.common.result.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "collection")
public class CollectionDbController {
    @Autowired
    private CollectionDbService collectionDbService;

     /**
     * 菜谱收藏
     * @param collectionDbEntity
     * @return
     */
    @RequestMapping(value = "addCollection",method = RequestMethod.POST)
    public Result addCollection(CollectionDbEntity collectionDbEntity){
        return collectionDbService.addCollection(collectionDbEntity);
    }


    /**
     * 获取收藏菜谱数据
     * @param cVo
     * @return
     */
    @RequestMapping(value = "findCollection",method = RequestMethod.POST)
    public ResultModel<PageInfo<CollectionDbVo>> findCollection(CollectionDbVo cVo){
        return collectionDbService.findCollection(cVo);
    }

    /**
     * 删除收藏菜谱
     * @param menu_url
     * @param user_id
     * @return
     */
    @RequestMapping(value = "deldeCollection")
    public Result deldeCollection(@RequestParam("menu_url") String menu_url,@RequestParam("user_id") String user_id){
        return collectionDbService.deldeCollection(menu_url,user_id);
    }
}
